﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace Scap.Info
{
    public class ScapDevice
    {      
        public int Id { get; set; }
        
        [Required]
        [Display(Name = "Nombre")]
        public string Name { get; set; }
                
        public int TimeZone { get; set; }

        public string SerialNumber { get; set; }

        [Required]
        public ConnectionType Connection { get; set; }

        [Required]
        [Display(Name = "IP")]        
        public string IpAddress { get; set; }

        [Required]
        [Range(100, 40000)]
        [Display(Name = "Puerto")]
        public int IpPort { get; set; }

        [Display(Name = "Clave de comunicación")]
        public string CommunicationKey { get; set; }

        [Display(Name = "Estado")]
        public DeviceStatus Status { get; set; }

        public string StatusMessage { get; set; }

        public int DepartmentId { get; set; }
        [ForeignKey("DepartmentId")]
        public ScapDepartment Department { get; set; }

        [Required]
        public bool NotifyOnDisconnect;

        
    }

    public enum ConnectionType
    {
         None=0
        ,Tcp=1
    }

    public enum DeviceStatus
    {
         Offline
        ,Online
    }

    public class ScapDeviceComparer : IEqualityComparer<ScapDevice>
    {

        public bool Equals(ScapDevice x, ScapDevice y)
        {
            return x.Id.Equals(y.Id);
        }

        public int GetHashCode(ScapDevice obj)
        {
            return obj.GetHashCode();
        }
    }

}
